<!--author:zk-->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>排行</title>
    <script src="js/jquery.min.js"></script>
    <meta name="description" content="Charcoal is a free Bootstrap 4 UI kit build by @attacomsian at Wired Dots."/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!--Bootstrap 4-->
    <link rel="stylesheet" href="css/bootstrap.css">
    <style>
        .refresh{
            width: 120px;
            height: 44px;
            font-size: 16px;
            position: absolute;
            outline: none;
            cursor: pointer;
            display: inline;
            right:210px;
            color: #fff;
            background-color: #5bc0de;
            border: 0;
            border-radius: 10px;
            font-size: 18px;
        }
        .refresh:hover{
            background-color: #97d3e7;
        }
        .contain {
            width: 500px;
            height: 50px;
            margin: 100px auto;
        }

        .parent {
            width: 100%;
            height: 42px;
            top: 4px;
            position: relative;
        }

        .parent > input:first-of-type {
            /*输入框高度设置为40px, border占据2px，总高度为42px*/
            border-radius: 8px;
            width: 380px;
            height: 43px;
            border: 1px solid #ccc;
            font-size: 16px;
            outline: none;
            margin-right: 20px;
        }

        .parent > input:first-of-type:focus {
            border: 1px solid #317ef3;
            padding-left: 10px;
        }

        .parent > input:last-of-type {
            /*button按钮border并不占据外围大小，设置高度42px*/
            width: 100px;
            height: 44px;
            position: absolute;
            background-color: #5bc0de;
            border: 1px solid #3ed4e8;
            border-radius: 8px;
            color: #fff;
            font-size: 16px;
            outline: none;
        }
        .parent > input:last-of-type:hover{
            background-color: #97d3e7;
        }

        .dropbtn {
            background-color: transparent;
            color: white;
            padding-left: 35px;
            padding-right: 35px;
            font-size: 16px;
            border: none;
            cursor: pointer;
        }

        .dropdown {
            position: relative;
            display: inline-block;
            text-align: center;
        }

        .dropdown-content {
            display: none;
            position: absolute;
            background-color: #f9f9f9;
            width: 100%;;
            box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
        }

        .dropdown-content a {
            color: black;
            padding: 12px 16px;
            text-decoration: none;
            display: block;
        }

        .dropdown-content a:hover {
            background-color: #f1f1f1
        }

        .dropdown:hover .dropdown-content {
            display: block;
        }

        .dropdown:hover .dropbtn {
            background-color: transparent;
        }

        /*导航栏样式*/
        .navbar {
            background-color: #222;
        }
        #daohang {
            list-style-type: none;
            margin: 0;
            padding: 0;
            overflow: hidden;
            background-color: transparent;
        }
        li {
            height: 40px;
            padding-left: 0;
            padding-right: 20px;
            font-size: 15px;
            float: left;
        }
        li a {
            padding: 10px;
            display: block;
            color: white;
            text-align: center;
            /*padding: 14px 16px;*/
            text-decoration: none;
        }
        /*!*鼠标移动到选项上修改背景颜色 *!*/
        li a:hover {
            background-color: #111;
        }
        .active {
            background-color: black;
        }

        /*.page_btn{*/
        /*    border-radius:4px;*/
        /*    border:1px solid #e5e9ef;*/
        /*    background:#fff;*/
        /*    margin-right:10px;*/
        /*    text-align:center;*/
        /*    width:70px;*/
        /*    height:24px;*/
        /*    line-height: 4px;*/
        /*    margin-top:3px;*/
        /*    outline:0;*/
        /*}*/

        /*.page_btn:hover{*/
        /*    border:1px solid #4f90fb;*/
        /*    color:#4f90fb;*/
        /*}*/

        .even
        {
            background-color: white;
        }
        button{
            padding-left: 20px;
            padding-right: 20px;
            padding-top: 5px;
            padding-bottom: 5px;
            color: #fff;
            background-color: #5bc0de;
            border: 0;
            border-radius: 10px;
        }
        button:hover{
            background-color: #97d3e7;
        }

    </style>
</head>
<body>

<nav class="navbar navbar-expand-md navbar-dark fixed-top sticky-navigation">
    <a class="navbar-brand font-weight-bold" href="index.html">别叫我OJ</a>
    <ul id="daohang">
        <li>
            <div  id="index" align="right">
                <a style="color: white" href="index.html">首页</a>
            </div>
        </li>
        <li>
            <div  id="remind" align="right">
                <a style="color: white" href="questionbank.html">题库</a>
            </div>
        </li>
        <li>
            <div class="active" id="rank" align="right">
                <a style="color: white" href="rank.html">排名</a>
            </div>
        </li>
        <li>
            <div  id="userDetail" align="right">
                <a style="color: white" href="userDetail.html">个人中心</a>
            </div>
        </li>
        <li>
            <div id="ai" align="right">
                <a style="color: white" href="ai.html">Ai聊天</a>
            </div>
        </li>
    </ul>
    <div class="collapse navbar-collapse" id="topMenu">
        <ul class="navbar-nav ml-auto">
            <div style="margin:5px" id="javaoj">
                <span style="margin-right: 20px;color: #ffffff">欢迎！<a id="username" href="userDetail.html"></a></span>
                <a style="color: white" href="login.html" onclick="logout()"> 退出登录</a>
                <div class="dropdown">
                    <button class="dropbtn">设置</button>
                    <div class="dropdown-content">
                        <a href="updateInfo.html">修改个人信息</a>
                        <a href="updatePassword.html">修改密码</a>
                    </div>
                </div>
            </div>
        </ul>
    </div>
</nav>
<div class="contain" style="padding-top: 100px">
    <form action="" class="parent">
        <input type="text" id="searchContent" placeholder="&nbsp;&nbsp;输入学号来查询">
        <input type="button" onclick="searchById()" value="搜索" style="cursor: pointer">
    </form>
</div>

<!--components-->
<section class="my-5 pt-5">
    <div class="container">
        <!-- Tables  -->
        <h3 style="display: inline" id="banner">排名每30分钟更新一次!</h3><h3 style="display: inline"></h3>
        <input type="button" onclick="refreshPage()" class="refresh" value="重置">
        <div class="row mb-5" id="tables">
            <div class="col-sm-12" style="background-color: white;margin-top: 20px">
                <div class="mt-3 mb-5">
                    <table class="table table-striped" id="shareContent" style="background-color: #f5f5f5">

                    </table>
                </div>
            </div>
        </div>
    </div>
</section>
<!--footer-->
<section class="py-5 bg-dark">
    <div class="container">
        <div class="row">
            <div class="col-md-6 offset-md-3 col-sm-8 offset-sm-2 col-xs-12 text-center">
                <p class="pt-2 text-muted">
                    &copy; by <a href="aboutUs.html" target="_blank">别叫我们组</a>
                </p>

            </div>
        </div>
    </div>
</section>
<!-- <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js"></script>-->
<!--<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.3/umd/popper.min.js"></script>-->
<!--<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js"></script>-->
<!--<script src="js/app.js"></script>-->
<script>
    console.log(checkGender("M"));
    var userId=localStorage.getItem("userId");
    var name=localStorage.getItem("username");
    let username = document.getElementById("username");
    //如果没有设置用户名，则显示id
    if(isEmpty(name)){
        username.innerText=userId;
    }else{
        username.innerText= name;
    }
    //您的当前排名是：的元素
    let banner=document.getElementById("banner");
    //将后端获取到的排名添加到ranking的innerText中
    // let ranking = document.getElementById("ranking");
    //搜索框节点
    let searchContent=document.getElementById("searchContent");
    //搜索框里的内容
    let otherId;
    //当前页页码
    let nowPage=1;
    //总页数
    let totalPage;
    //每页有多少个数据
    let size;
    //用户id
    var userId=localStorage.getItem("userId");
    //一上来跑的数据
    $(document).ready(function(){
        searchContent.value="";
        $.ajax({
            url:"http://192.168.2.5:8010/user/queryRank?page="+nowPage,
            //data是返回值 所有数据
            success:function (object) {
                console.log(object);
                let shareHtml="<tr><th>名次</th><th>用户</th><th>昵称</th><th>性别</th><th>AC题数</th></tr>";
                let array=object.data.content;
                size=object.data.size;
                totalPage=object.data.totalPages;
                console.log(shareHtml);
                for(let i=0;i<array.length;i++){
                    let rank=(nowPage-1)*size+i+1;
                    if(array[i].id===userId){
                        shareHtml+='<tr style="color: red">' +
                            '<td>'+rank+'</td>\n' +
                            '<td>'+array[i].id+'</td>\n' +
                            '<td>'+array[i].username+'</td>\n' +
                            '<td>'+checkGender(array[i].gender)+'</td>\n' +
                            '<td>'+array[i].acCount+'</td>\n' +
                            '</tr>';
                    }else{
                        shareHtml+='<tr>' +
                            '<td>'+rank+'</td>\n' +
                            '<td>'+array[i].id+'</td>\n' +
                            '<td>'+array[i].username+'</td>\n' +
                            '<td>'+checkGender(array[i].gender)+'</td>\n' +
                            '<td>'+array[i].acCount+'</td>\n' +
                            '</tr>';
                    }
                }
                shareHtml+="<tr>" +
                    "<td colspan='5' style='text-align: center'><button style='margin-left: 20px' class='page_btn' href='#' onclick='firstPage()'>首页</button>" +
                    "<button style='margin-left: 20px' class='page_btn' href='#' onclick='previousPage()'>上一页</button>" +
                    "<button style='margin-left: 20px' class=page_btn style='width: 150px'>"+" 第 "+nowPage+" / "+totalPage+" 页 "+"</button>" +
                    "<button style='margin-left: 20px' class='page_btn'  href='#' onclick='nextPage()'>下一页</button>" +
                    "<button style='margin-left: 20px' class='page_btn'  href='#' onclick='lastPage()'>末页</button</td>" +
                    "</tr>"
                //shareContent为留出来填充内容的div的id名
                $("#shareContent").html(shareHtml);

                //表格单双行变色
                $().ready(function(){
                    $('tr:even').addClass('even');
                });
            }
        })
    })
    //跳转到第一页的方法
    function firstPage(){
        nowPage=1;
        $.ajax({
            url:"http://192.168.2.5:8010/user/queryRank?page="+nowPage,
            //data是返回值 所有数据
            success:function (object) {
                console.log(object);
                let shareHtml="<tr><th>名次</th><th>用户</th><th>昵称</th><th>性别</th><th>AC题数</th></tr>";
                let array=object.data.content;
                size=object.data.size;
                totalPage=object.data.totalPages;
                console.log(shareHtml);
                for(let i=0;i<array.length;i++){
                    let rank=(nowPage-1)*size+i+1;
                    if(array[i].id===userId){
                        shareHtml+='<tr style="color: red">' +
                            '<td>'+rank+'</td>\n' +
                            '<td>'+array[i].id+'</td>\n' +
                            '<td>'+array[i].username+'</td>\n' +
                            '<td>'+checkGender(array[i].gender)+'</td>\n' +
                            '<td>'+array[i].acCount+'</td>\n' +
                            '</tr>';
                    }else{
                        shareHtml+='<tr>' +
                            '<td>'+rank+'</td>\n' +
                            '<td>'+array[i].id+'</td>\n' +
                            '<td>'+array[i].username+'</td>\n' +
                            '<td>'+checkGender(array[i].gender)+'</td>\n' +
                            '<td>'+array[i].acCount+'</td>\n' +
                            '</tr>';
                    }
                }
                shareHtml+="<tr>" +
                    "<td colspan='5' style='text-align: center'><button style='margin-left: 20px' class='page_btn' href='#' onclick='firstPage()'>首页</button>" +
                    "<button style='margin-left: 20px' class='page_btn' href='#' onclick='previousPage()'>上一页</button>" +
                    "<button style='margin-left: 20px' class=page_btn style='width: 150px'>"+" 第 "+nowPage+" / "+totalPage+" 页 "+"</button>" +
                    "<button style='margin-left: 20px' class='page_btn'  href='#' onclick='nextPage()'>下一页</button>" +
                    "<button style='margin-left: 20px' class='page_btn'  href='#' onclick='lastPage()'>末页</button</td>" +
                    "</tr>"
                //shareContent为留出来填充内容的div的id名
                $("#shareContent").html(shareHtml);
                //表格单双行变色
                $().ready(function(){
                    $('tr:even').addClass('even');
                });
            }
        })
    }
    //跳转到上一页的方法
    function previousPage() {
        nowPage=nowPage-1;
        if(nowPage===0){
            nowPage=1;
            alert("这已经是第一页了");
        }else{
            $.ajax({
                url:"http://192.168.2.5:8010/user/queryRank?page="+nowPage,
                //data是返回值 所有数据
                success:function (object) {
                    let shareHtml="<tr><th>名次</th><th>用户</th><th>昵称</th><th>性别</th><th>AC题数</th></tr>";
                    let array=object.data.content;
                    size=object.data.size;
                    totalPage=object.data.totalPages;
                    for(let i=0;i<array.length;i++){
                        let rank=(nowPage-1)*size+i+1;
                        if(array[i].id===userId){
                            shareHtml+='<tr style="color: red">' +
                                '<td>'+rank+'</td>\n' +
                                '<td>'+array[i].id+'</td>\n' +
                                '<td>'+array[i].username+'</td>\n' +
                                '<td>'+checkGender(array[i].gender)+'</td>\n' +
                                '<td>'+array[i].acCount+'</td>\n' +
                                '</tr>';
                        }else{
                            shareHtml+='<tr>' +
                                '<td>'+rank+'</td>\n' +
                                '<td>'+array[i].id+'</td>\n' +
                                '<td>'+array[i].username+'</td>\n' +
                                '<td>'+checkGender(array[i].gender)+'</td>\n' +
                                '<td>'+array[i].acCount+'</td>\n' +
                                '</tr>';
                        }
                    }
                    shareHtml+="<tr>" +
                        "<td colspan='5' style='text-align: center'><button style='margin-left: 20px' class='page_btn' href='#' onclick='firstPage()'>首页</button>" +
                        "<button style='margin-left: 20px' class='page_btn' href='#' onclick='previousPage()'>上一页</button>" +
                        "<button style='margin-left: 20px' class=page_btn style='width: 150px'>"+" 第 "+nowPage+" / "+totalPage+" 页 "+"</button>" +
                        "<button style='margin-left: 20px' class='page_btn'  href='#' onclick='nextPage()'>下一页</button>" +
                        "<button style='margin-left: 20px' class='page_btn'  href='#' onclick='lastPage()'>末页</button</td>" +
                        "</tr>"
                    //shareContent为留出来填充内容的div的id名
                    $("#shareContent").html(shareHtml);
                    //表格单双行变色
                    $().ready(function(){
                        $('tr:even').addClass('even');
                    });
                }
            })
        }
    }
    //跳转到下一页的方法
    function nextPage() {
        nowPage=nowPage+1;
        if(nowPage===totalPage+1){
            nowPage=totalPage;
            alert("这已经是最后一页了");
        }
        $.ajax({
            url:"http://192.168.2.5:8010/user/queryRank?page="+nowPage,
            //data是返回值 所有数据
            success:function (object) {
                console.log(object);
                let shareHtml="<tr><th>名次</th><th>用户</th><th>昵称</th><th>性别</th><th>AC题数</th></tr>";
                let array=object.data.content;
                size=object.data.size;
                totalPage=object.data.totalPages;
                console.log(shareHtml);
                for(let i=0;i<array.length;i++){
                    let rank=(nowPage-1)*size+i+1;
                    if(array[i].id===userId){
                        shareHtml+='<tr style="color: red">' +
                            '<td>'+rank+'</td>\n' +
                            '<td>'+array[i].id+'</td>\n' +
                            '<td>'+array[i].username+'</td>\n' +
                            '<td>'+checkGender(array[i].gender)+'</td>\n' +
                            '<td>'+array[i].acCount+'</td>\n' +
                            '</tr>';
                    }else{
                        shareHtml+='<tr>' +
                            '<td>'+rank+'</td>\n' +
                            '<td>'+array[i].id+'</td>\n' +
                            '<td>'+array[i].username+'</td>\n' +
                            '<td>'+checkGender(array[i].gender)+'</td>\n' +
                            '<td>'+array[i].acCount+'</td>\n' +
                            '</tr>';
                    }
                }
                shareHtml+="<tr>" +
                    "<td colspan='5' style='text-align: center'><button style='margin-left: 20px' class='page_btn' href='#' onclick='firstPage()'>首页</button>" +
                    "<button style='margin-left: 20px' class='page_btn' href='#' onclick='previousPage()'>上一页</button>" +
                    "<button style='margin-left: 20px' class=page_btn style='width: 150px'>"+" 第 "+nowPage+" / "+totalPage+" 页 "+"</button>" +
                    "<button style='margin-left: 20px' class='page_btn'  href='#' onclick='nextPage()'>下一页</button>" +
                    "<button style='margin-left: 20px' class='page_btn'  href='#' onclick='lastPage()'>末页</button</td>" +
                    "</tr>"
                //shareContent为留出来填充内容的div的id名
                $("#shareContent").html(shareHtml);
                //表格单双行变色
                $().ready(function(){
                    $('tr:even').addClass('even');
                });
            }
        })
    }
    //跳转到末页的方法
    function lastPage() {
        nowPage=totalPage;
        $.ajax({
            url:"http://192.168.2.5:8010/user/queryRank?page="+nowPage,
            //data是返回值 所有数据
            success:function (object) {
                console.log(object);
                let shareHtml="<tr><th>名次</th><th>用户</th><th>昵称</th><th>性别</th><th>AC题数</th></tr>";
                let array=object.data.content;
                size=object.data.size;
                totalPage=object.data.totalPages;
                console.log(shareHtml);
                for(let i=0;i<array.length;i++){
                    let rank=(nowPage-1)*size+i+1;
                    if(array[i].id===userId){
                        shareHtml+='<tr style="color: red">' +
                            '<td>'+rank+'</td>\n' +
                            '<td>'+array[i].id+'</td>\n' +
                            '<td>'+array[i].username+'</td>\n' +
                            '<td>'+checkGender(array[i].gender)+'</td>\n' +
                            '<td>'+array[i].acCount+'</td>\n' +
                            '</tr>';
                    }else{
                        shareHtml+='<tr>' +
                            '<td>'+rank+'</td>\n' +
                            '<td>'+array[i].id+'</td>\n' +
                            '<td>'+array[i].username+'</td>\n' +
                            '<td>'+checkGender(array[i].gender)+'</td>\n' +
                            '<td>'+array[i].acCount+'</td>\n' +
                            '</tr>';
                    }
                }
                shareHtml+="<tr>" +
                    "<td colspan='5' style='text-align: center'><button style='margin-left: 20px' class='page_btn' href='#' onclick='firstPage()'>首页</button>" +
                    "<button style='margin-left: 20px' class='page_btn' href='#' onclick='previousPage()'>上一页</button>" +
                    "<button style='margin-left: 20px' class=page_btn style='width: 150px'>"+" 第 "+nowPage+" / "+totalPage+" 页 "+"</button>" +
                    "<button style='margin-left: 20px' class='page_btn'  href='#' onclick='nextPage()'>下一页</button>" +
                    "<button style='margin-left: 20px' class='page_btn'  href='#' onclick='lastPage()'>末页</button</td>" +
                    "</tr>"
                //shareContent为留出来填充内容的div的id名
                $("#shareContent").html(shareHtml);
                //表格单双行变色
                $().ready(function(){
                    $('tr:even').addClass('even');
                });
            }
        })
    }
    //一进入排行界面从后端拿自己排行的函数
    // function getRanking(userId){
    //     $.ajax({
    //         url: "http://192.168.47.129:8010/user/queryOwnRank?id="+userId,
    //         type: "GET",
    //         success: function (object) {
    //             let ownRank=object.data.rank;
    //             ranking.innerText = ownRank;
    //         },
    //         error:function () {
    //             banner.innerText="数据还未更新"
    //         }
    //     })
    // }
    //点击搜索按钮发生的点击事件
    function searchById() {
        if(isEmpty(searchContent.value)){
            alert("搜索内容不能为空！");
            return;
        }
        if(searchContent.value===otherId){
            alert("请输入不同的学号！");
        }else{
            otherId=searchContent.value;
            $.ajax({
                url:"http://192.168.2.5:8010/user/queryOwnRank?id="+otherId,
                //data是返回值 所有数据
                success:function (object) {
                    console.log(object);
                    let code=object.code;
                    if(code==="200"){
                        let ownRank=object.data.rank;
                        let content=object.data.userDTO;
                        let shareHtml="<tr><th>名次</th><th>用户</th><th>昵称</th><th>性别</th><th>AC题数</th></tr>";
                        if(content.id===userId){
                            shareHtml+='<tr style="color: red">' +
                                '<td>'+ownRank+'</td>\n' +
                                '<td>'+content.id+'</td>\n' +
                                '<td>'+content.username+'</td>\n' +
                                '<td>'+checkGender(content.gender)+'</td>\n' +
                                '<td>'+content.acCount+'</td>\n' +
                                '</tr>';
                        }else{
                            shareHtml+='<tr>' +
                                '<td>'+ownRank+'</td>\n' +
                                '<td>'+content.id+'</td>\n' +
                                '<td>'+content.username+'</td>\n' +
                                '<td>'+checkGender(content.gender)+'</td>\n' +
                                '<td>'+content.acCount+'</td>\n' +
                                '</tr>';
                        }
                        console.log(shareHtml);
                        //shareContent为留出来填充内容的div的id名
                        $("#shareContent").html(shareHtml);
                        //表格单双行变色
                        $().ready(function(){
                            $('tr:even').addClass('even');
                        });
                    }else if(code==="500"){
                        alert("用户不存在或者输入学号有误！");
                    }
                }
            })
        }
    }
    function refreshPage(){
        nowPage=1;
        searchContent.value="";
        $.ajax({
            url:"http://192.168.2.5:8010/user/queryRank?page="+nowPage,
            //data是返回值 所有数据
            success:function (object) {
                console.log(object);
                let shareHtml="<tr><th>名次</th><th>用户</th><th>昵称</th><th>性别</th><th>AC题数</th></tr>";
                let array=object.data.content;
                size=object.data.size;
                totalPage=object.data.totalPages;
                console.log(shareHtml);
                for(let i=0;i<array.length;i++){
                    let rank=(nowPage-1)*size+i+1;
                    if(array[i].id===userId){
                        shareHtml+='<tr style="color: red">' +
                            '<td>'+rank+'</td>\n' +
                            '<td>'+array[i].id+'</td>\n' +
                            '<td>'+array[i].username+'</td>\n' +
                            '<td>'+checkGender(array[i].gender)+'</td>\n' +
                            '<td>'+array[i].acCount+'</td>\n' +
                            '</tr>';
                    }else{
                        shareHtml+='<tr>' +
                            '<td>'+rank+'</td>\n' +
                            '<td>'+array[i].id+'</td>\n' +
                            '<td>'+array[i].username+'</td>\n' +
                            '<td>'+checkGender(array[i].gender)+'</td>\n' +
                            '<td>'+array[i].acCount+'</td>\n' +
                            '</tr>';
                    }
                }
                shareHtml+="<tr>" +
                    "<td colspan='5' style='text-align: center'><button style='margin-left: 20px' class='page_btn' href='#' onclick='firstPage()'>首页</button>" +
                    "<button style='margin-left: 20px' class='page_btn' href='#' onclick='previousPage()'>上一页</button>" +
                    "<button style='margin-left: 20px' class=page_btn style='width: 150px'>"+" 第 "+nowPage+" / "+totalPage+" 页 "+"</button>" +
                    "<button style='margin-left: 20px' class='page_btn'  href='#' onclick='nextPage()'>下一页</button>" +
                    "<button style='margin-left: 20px' class='page_btn'  href='#' onclick='lastPage()'>末页</button</td>" +
                    "</tr>"
                //shareContent为留出来填充内容的div的id名
                $("#shareContent").html(shareHtml);
                //表格单双行变色
                $().ready(function(){
                    $('tr:even').addClass('even');
                });
            }
        })
    }
    //获取用户登录信息，获取失败则返回登录页面
    function getUser(){
        if (userId==null){
            location.assign("login.html");
        }
    }
    function logout(){
        localStorage.clear();
    }
    getRanking(userId);
    getUser();
    //判断字符串是否为空的函数 true表示是空字符串
    function isEmpty(password) {
        if(password === '' || password.trim().length === 0){
            return true;
        }else{
            return false;
        }
    }
    function checkGender(gender){
        if(gender=="M"){
            return "男";
        }else{
            return "女"
        }
    }
    function checkSelf(id){
        if(id===userId){
            return '<td style="color:red">'+id+'</td>\n' ;
        }else{
            return '<td>'+id+'</td>\n' ;
        }
    }

    function getAdmin(){
        console.log(userId);
        console.log(password);
        let user={
            "id" : userId.valueOf(),
            "password" : password.valueOf(),
        };
        $.ajax({
            url:"http://192.168.2.5:8010/admin/login?id="+user.id+"&password="+user.password,
            type:"GET",
            success: function (data) {
                let msg=data.msg;
                if(msg==="登录成功") {
                    console.error("管理员yyds");
                    isAdminUser();
                }
            }
        })
    }
    function isAdminUser(){
        // Create the new <li> element
        const newListItem = document.createElement('li');

        // Create the new <div> element
        const newDiv = document.createElement('div');
        newDiv.style.marginLeft = '20px';
        newDiv.id = 'manager';
        newDiv.align = 'right';

        // Create the new <a> element
        const newLink = document.createElement('a');
        newLink.style.color = 'white';
        newLink.href = 'manager.html';
        newLink.textContent = '管理员中心';

        // Append the <a> element to the <div> element

        newDiv.appendChild(newLink);
        // Append the <div> element to the <li> element
        newListItem.appendChild(newDiv);

        // Append the new <li> element to the existing <ul> element
        const navigationList = document.getElementById('daohang');
        navigationList.appendChild(newListItem);

    }
    getAdmin();

</script>
</body>
</html>
